Skip to content

Add multi-module support to Go "templates" #136

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 12, 2021
Merged

Add multi-module support to Go "templates" #136

merged 2 commits into from
Aug 12, 2021

Conversation

per1234
Copy link
Contributor

@per1234 per1234 commented Aug 12, 2021

The templates for testing, linting, and formatting Go code work from a list of packages of the Go module which is output
from a go list command. Previously, it was only possible to get the packages of the module in the root of the repository.

Projects may contain multiple Go modules in subfolders of the repository. In order to support checks on these modules,
it's necessary to configure the commands to run from their path. This is passed to the task via the GO_MODULE_PATH
environment variable. If this variable is not defined, the default root module path is used as default, preserving the
previous task behavior.

The workflows use a job matrix to allow easy configuration for any number of module paths and a dedicated parallel job
for each module.

Because it may not be desirable to combine the code coverage data for all modules, a Codecov flag value can be defined for each matrix job in the "Test Go" workflow. This workflow produces a two dimensional "operating system * module" job matrix, running the tests for each module using all operating systems.


Demo of "Check Go" template in action: https://github.com/arduino/arduino-cli/actions/runs/1123382544

Demo of "Test Go" template in action: https://github.com/per1234/arduino-lint/actions/runs/1123365635

The installation instructions for all templates that require the `DEFAULT_GO_PACKAGES` taskfile variable point to the
"go-task" asset taskfile as its source. However, there was a redundant copy of this variable in the "check-go-task" asset
taskfile.

Maintaining two copies of this fairly complex asset is difficult, for no benefit in return, so it must be removed.
The templates for testing, linting, and formatting Go code work from a list of packages of the Go module which is output
from a `go list` command. Previously, it was only possible to get the packages of the module in the root of the repository.

Projects may contain multiple Go modules in subfolders of the repository. In order to support checks on these modules,
it's necessary to configure the commands to run from their path. This is passed to the task via the `GO_MODULE_PATH`
environment variable. If this variable is not defined, the default root module path is used as default, preserving the
previous task behavior.

The workflows use a job matrix to allow easy configuration for any number of module paths and a dedicated parallel job
for each module.

Because it may not be desirable to combine the code coverage data for all modules, a Codecov flag value can be defined
for each matrix job in the "Test Go" workflow. This workflow produces a two dimensional "operating system * module" job
matrix, running the tests for each module using all operating systems.
@per1234 per1234 added type: enhancement Proposed improvement topic: code Related to content of the project itself labels Aug 12, 2021
@per1234 per1234 merged commit 6355b7c into arduino:main Aug 12, 2021
@per1234 per1234 deleted the multi-module branch August 12, 2021 10:24
@per1234 per1234 self-assigned this Nov 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: code Related to content of the project itself type: enhancement Proposed improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants